package at.fhj.itm.jface;



import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Display;

import at.fhj.itm.metadata.Column;

public class FancyColumnLabelProvider extends LabelProvider implements
		IFontProvider, IColorProvider {

	private final Color DEFAULT_FG_COLOR;
	private final Color PK_FG_COLOR;
	
	public FancyColumnLabelProvider() {

		Display display = Display.getCurrent();
		DEFAULT_FG_COLOR = display.getSystemColor(SWT.COLOR_DARK_BLUE);
		PK_FG_COLOR = display.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
		
	}
	
	@Override
	public String getText(Object element) {
		Column column = (Column) element;
		
		if(column.isPrimaryKeyColumn()){
			return column.getName() + "(pk)";
		}
		
		return column.getName();
	}
	
	@Override
	public Color getForeground(Object element) {
		Column column = (Column) element;
		if(column.isPrimaryKeyColumn()){
			return PK_FG_COLOR;
		}
		return DEFAULT_FG_COLOR;
		
	}

	@Override
	public Color getBackground(Object element) {
		return null;
	}

	@Override
	public Font getFont(Object element) {
		return null;
	}

}
